import Layout from 'src/pages/layout/layout';

// 不作为main组件子页面展示的页面单独写，如下
export const loginRouter = {
  path: '/login',
  name: 'login',
  meta: {
    title: 'Login - 登录'
  },
  component: () => import('src/pages/login/login')
};

export const regisRouter = {
  path: '/register',
  name: 'register',
  meta: {
    title: '注册'
  },
  component: () => import('src/pages/register/register')
};

// 错误页面
export const errorRouter = {
  path: '/error/:code',
  name: 'error',
  meta: {
    title: 'error'
  },
  component: () => import('src/pages/error/index')
};

// 作为main组件子页面展示  但不在左侧菜单显示的路由卸载otherRoter里
export const otherRouter = {
  path: '',
  name: 'otherRouter',
  redirect: '/home',
  meta: {
    requireAuth: true,
    title: '主页'
  },
  component: Layout,
  children: [
    {
      path: 'home',
      name: 'home',
      component: () => import('src/pages/home/home'),
      meta: {
        title: '主页'
      }
    }
  ]
};

// 作为Main组件的子页面展示并且在左侧菜单显示的路由写在appRouter里
export const appRouter = [
  {
    path: '/bonus',
    name: 'bonus',
    title: '奖金明细',
    component: Layout,
    children: [
      {
        path: 'index',
        name: 'bonus_index',
        component: () => import('src/pages/bonus/index'),
        meta: {
          title: '奖金明细'
        }
      }
    ]
  },
  {
    path: '/team',
    name: 'team',
    title: '团队列表',
    component: Layout,
    children: [
      {
        path: 'charts',
        name: 'team_charts',
        component: () => import('src/pages/team/charts'),
        meta: {
          title: '图表显示'
        }
      }
    ]
  },
  {
    path: '/integral',
    name: 'integral',
    title: '积分交易',
    component: Layout,
    children: [
      {
        path: 'index',
        name: 'integral_index',
        component: () => import('src/pages/integral/index'),
        meta: {
          title: '积分交易'
        }
      }
    ]
  },
  {
    path: '/user',
    name: 'user',
    title: '个人资料',
    component: Layout,
    children: [
      {
        path: 'index',
        name: 'user_index',
        component: () => import('src/pages/user/index'),
        meta: {
          title: '个人资料'
        }
      }
    ]
  },
  {
    path: '/success',
    name: 'success',
    title: '成功提示',
    component: Layout,
    children: [
      {
        path: 'index',
        name: 'success_index',
        component: () => import('src/pages/msg/index'),
        meta: {
          title: '成功提示'
        }
      }
    ]
  },
  {
    path: '/test',
    name: 'test',
    title: '测试',
    component: Layout,
    children: [
      {
        path: 'index',
        name: 'test_index',
        component: () => import('src/pages/test/test'),
        meta: {
          title: '测试'
        }
      }
    ]
  }
];

export const routers = [
  loginRouter,
  regisRouter,
  errorRouter,
  otherRouter,
  ...appRouter
];
